package logic

import (
	"context"
	"friend/common"
	"friend/models"

	"friend/internal/svc"
	"friend/pb/friend"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelGroupLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelGroupLogic {
	return &DelGroupLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DelGroup 好友分组删除
func (l *DelGroupLogic) DelGroup(in *friend.GroupInfo) (*friend.Empty, error) {
	err := l.svcCtx.FriendGroupModel.Update(l.ctx, &models.FriendGroup{
		Id:     in.Id,
		Status: common.FriendGroupStatusDel,
	})
	if err != nil {
		return nil, err
	}
	return &friend.Empty{}, nil
}
